package cn.bearspark.user.provider.dao.key;

import cn.bearspark.framework.redis.starter.buffer.hash.un.RedisHashBufferKeyBuilder;
import cn.bearspark.framework.redis.starter.key.RedisKeyBuilder;
import org.springframework.stereotype.Component;

/**
 * 用户模块中 redis 缓存键的构造器
 *
 * @author f
 */
@Component
public class UserBufferKeyBuilder extends RedisKeyBuilder implements RedisHashBufferKeyBuilder {

    /**
     * 用户信息缓存的键的前缀
     */
    private static final String USER_INFO = "userInfo";

    /**
     * 用户关注者的 id 缓存的键的前缀
     */
    private static final String FOLLOWERS_ID_INFO = "followersIdInfo";

    /**
     * 用户粉丝的 id 缓存的键的前缀
     */
    private static final String FANS_ID_INFO = "fansIdInfo";

    /**
     * 用户 id 与 用户名 缓存的键的前缀
     */
    private static final String USER_ID_NAME_INFO = "userIdNameInfo";

    @Override
    public String buildHashBufferKey(long id) {
        return super.getPrefix() + USER_INFO + super.getSplitItem() + id;
    }

    public String buildFollowersIdKey(long userId) {
        return super.getPrefix() + FOLLOWERS_ID_INFO + super.getSplitItem() + userId;
    }

    public String buildFansIdKey(long userId) {
        return super.getPrefix() + FANS_ID_INFO + super.getSplitItem() + userId;
    }

    public String buildUserIdNameMapKey() {
        return super.getPrefix() + USER_ID_NAME_INFO;
    }
}
